using System;
using Gtk;

public partial class MainWindow : Gtk.Window
{
	private Widget invisible = null;
	private int paginasCreadas = 0;
	public MainWindow () : base(Gtk.WindowType.Toplevel)
	{

		Build ();
		
		
		notebook.SwitchPage += delegate {
			removeAction.Sensitive = notebook.CurrentPage > -1;
		};
		
		notebook.PageRemoved += delegate {
			removeAction.Sensitive = notebook.CurrentPage > -1;
		};
		
		removeAction.Sensitive = notebook.CurrentPage > -1;
		
		addAction.Activated += delegate {
			TreeView treeView = new TreeView();
			treeView.Visible = true;
			
			HBox hBox = new HBox();
			Label label = new Label("Página nueva " + paginasCreadas++);
			label.Visible = true;
			hBox.Add(label);
			Button button = new Button();
			button.Image = Image.NewFromIconName(Stock.Close, IconSize.Button);
			button.Visible = true;
			hBox.Add(button);
			
			button.Clicked += delegate {
				notebook.Remove(treeView);
			};
			
			notebook.CurrentPage = notebook.AppendPage(treeView, hBox);
		};
		
		removeAction.Activated += delegate {
			Widget widget = notebook.CurrentPageWidget;
			notebook.Remove(widget);
		};
		
	}

	protected void OnDeleteEvent (object sender, DeleteEventArgs a)
	{
		Application.Quit ();
		a.RetVal = true;
	}
}
